import { reqCategoryList, reqVipcloth, reqLtart, reqBrand } from "@/api/home"

export default {
  state: {
    cateGoryList: [],
    floorList: [],
    tartList: {},
    brandList: []
  },
  mutations: {
    UPDATE_CATEGORYLIST (state, cateGoryList) {
      state.cateGoryList = cateGoryList
    },
    UPDATE_VIPCLOTH (state, floorList) {
      state.floorList = floorList
    },
    UPDATE_LTART (state, tartList) {
      state.tartList = tartList
    },
    UPDATE_Brand (state, brandList) {
      state.brandList = brandList
    }
  },
  actions: {
    // 获取三级分类数据
    async getCategoryList ({ commit }) {
      const res = await reqCategoryList()
      if (res.code === 200) {
        commit('UPDATE_CATEGORYLIST', res.data.slice(0, -7))
        return 'ok'
      } else {
        return Promise.reject('fail')
      }
    },

    async getVipcloth ({ commit }) {
      const res = await reqVipcloth()
      commit('UPDATE_VIPCLOTH', res)
    },

    async getLtart ({ commit }) {
      const res = await reqLtart()
      commit('UPDATE_LTART', res)
    },

    async getBrand ({ commit }) {
      const res = await reqBrand()
      commit('UPDATE_Brand', res)
    }
  },
  getters: {

  }
}

